var hrzgs = ['华融金控','华融华侨','华融海外(香港)','华融融德','华融融德香港','华融福建','华融汇通','华融公望','华融民仑','华融创新','华融致远','华融租赁','华融实业','华融(香港)产融投资','华融证券','华融信托','华融湘江银行','华融渝富','华融期货','华融国际','华融财富','华融西部','华融粤控','华融赣南','华融建投','华融晋商','华融消费金融','华融资本','华融交易中心','华融投资','华融新兴','华融澳门','华融凯迪','华融科技',];
var hrzgs2 = ['华融华侨',
'华融国际',
'华融澳门',
'华融资本',
'华融瑞通',
'华融汇通',
'华融晋商',
'华融实业',
'华融融德'];
var _render = function(param){
		var randomvalue = function() {return Math.floor(Math.random() * 100);}
		var arr = hrzgs2.slice(0,param.num);
		var _data = arr.map(val => ({name:val,value: randomvalue()}));
		var wordChart = echarts.init(document.getElementById("wordcloud"));
		console.log(param);
		var wordOpt = {
			backgroundColor: '#ddd',
			series: [{
				type: 'wordCloud',
				shape: param.shape, //circle cardioid diamond triangle-forward triangle
				left: 0,
				top: 0,
				right: 0,
				bottom:0,
				width: '100%',
				height: '100%',
				gridSize: param.gap, //值越大，word间的距离越大，单位像素
				textStyle: {fontFamily: '微软雅黑',color: function(){
					var colors = ['#fda67e', '#81cacc', '#cca8ba', "#88cc81", "#82a0c5", '#fddb7e', '#735ba1', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
			        return colors[parseInt(Math.random() * 10)];
				}},
				sizeRange: [param.min, param.max], //word的字体大小区间，单位像素
				rotationRange: [0, 0], //word的可旋转角度区间
				data: _data
			}]
		};
		wordChart.setOption(wordOpt,true);
	};

var refresh = function(){
	var _num = isNaN($('#word-cloud-num').val()) ? $('#word-cloud-num').val() : hrzgs2.length;
	var _shape = $('#word-cloud-shape').val();
	var _gap = parseInt($('#word-cloud-gap').val());
	var _max = parseInt($('#word-cloud-max').val());
	var _min = parseInt($('#word-cloud-min').val());
	
	var param = {};
	param.num = _num;
	param.shape = _shape;
	param.gap = _gap;
	param.max = _max;
	param.min = _min;
	
	_render(param);
};

$(function() {
	refresh();
});